package crm.view.setting.addremovelist;

import java.util.ArrayList;

import javax.swing.ListModel;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;

public class EnabledListModel implements ListModel {
	ArrayList enable; 
	ArrayList <ListDataListener> listener;
	EnabledListModel(ArrayList enable){
		this.enable = enable;
		listener = new ArrayList<ListDataListener>();
	}
	
	@Override
	public int getSize() {
		return enable.size();
	}
	
	@Override
	public Object getElementAt(int index) {
		
		return enable.get(index);
	}


	public void addListDataListener(ListDataListener l) {
		listener.add(l);
	}

	public void removeListDataListener(ListDataListener l) {
		listener.remove(l);
	}

	public void fireItemAddListener(int size){
		for (ListDataListener l : listener) {
			l.intervalAdded(new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, 0, size));
		}
		
	}
	public void fireItemRemoveListener(int size){
		for (ListDataListener l : listener) {
			l.intervalRemoved(new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, 0, size));
		}
		
	}
	
	


}

